home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 363 / xprolog2 / xprolog.doc < prev   
Text File  |  1985-11-19  |  25KB  |  806 lines

  1.  
  2.  
  3.             X Prolog Vers. 2.0
  4.  
  5.     This software is copyrighted by Andreas Toenne.
  6.     It may be copied free of charge iff this copyright notice
  7.     is left at it's place.
  8.  
  9.     Andreas Toenne
  10.     Computer Science Department
  11.     University of Dortmund, W-Germany
  12.     
  13.     E-mail : 
  14.         atoenne@unido.uucp
  15.         atoenne@unido.bitnet
  16.         ...!seismo!unido!atoenne
  17.         
  18.  
  19.     ***********************************************************
  20.     
  21.     Note ! This manual is just a quick hack to make Xprolog
  22.     available as fast as possible.
  23.     Sections that are missing are stated in '<' and '>'
  24.     Xprolog follows mostly the Cprolog standard, thus the
  25.     Cprolog manual could be of some help to the novice user
  26.  
  27.     ***********************************************************
  28.     
  29.  
  30.     1. Getting started.
  31.     
  32.     This program was developed with the Mark Williams C-Compiler Vers. 2.0
  33.     It was designed to live on a hard disk!
  34.     To start Xprolog simply double click xprolog.ttp without arguments.
  35.     Xprolog will try to read it's default image as : C:\BIN\PBOOT
  36.     If you don't have this directory or wish to start with another
  37.     image, enter the name as an argument for Xprolog.
  38.     You may set the enviroment variable BOOTFILE as well.
  39.     
  40.     1.1 Booting XProlog
  41.     
  42.     If you start Xprolog for the very first time, you must create
  43.     your own image.
  44.     This is done by calling Xprolog with the option -b.
  45.     Make sure that the bootfile _boot is present in the current directory.
  46.     You may save the image with 'save(Imagename).' then.
  47.     
  48.     1.2 Options
  49.     
  50.     You can specify the sizes of the various data areas with the
  51.     following options. The new size must be given in bytes.
  52.     
  53.     -p<size>     prototype space
  54.     -f<size>    functor space
  55.     -r<size>    number of rules (not bytes!)
  56.     -c<size>    copystack
  57.     -s<size>    THE STACK
  58.     -t<size>    trailstack
  59.     
  60.     The builtin predicate 'statistics' shows the current sizes of
  61.     all data areas.
  62.  
  63.     1.3 General
  64.     
  65.     The enviroment variable SHELL may be set if you don't have
  66.     msh.prg    or want to specify another shell.  (cf.  'system', 'sh')
  67.     <Control>C may be pressed anytime during computation.
  68.     Xprolog performs an abort then. (cf. 'abort')
  69.     
  70.     1.4 Explanation of Data Areas
  71.     
  72.     Prototype: a term in a prolog program
  73.     Prototype space: contains all prototypes. Forms a heap.
  74.     Rule space: contains descriptors for prolog rules. (clause space)
  75.         The rule's terms are kept in the prototype space.
  76.     Functor: general descriptor for prolog terms. Contains the name, arity
  77.         optional operator definitions and a link to it's rules.
  78.         Functors are kept in an avl-tree.
  79.     Copystack: keeps copies of prototypes. Grows during unification and
  80.         shrinks only upon backtracking.
  81.     THE STACK: keeps the computation data that makes up the resolution
  82.         tree. Highly dynamic !!
  83.     Trailstack: keeps trails (references) for variables that must be
  84.         preserved for backtracking. Usually very small.
  85.  
  86.     1.5 Limitations and Default Values
  87.     
  88.     - max. 20 arguments in a term
  89.     - max. 50 variables (without anonymous) in a prototype term
  90.     - max. 15 open streams
  91.     - the reader can read terms upto 8000 bytes
  92.     - max. 256 characters in a name
  93.     - the cpu stack is 32000 bytes wide
  94.     
  95.     - default shell is 'c:\bin\msh.prg'
  96.     - default bootimage is 'c:\bin\pboot'
  97.     - default prototype space size is 30000 bytes
  98.     - default copystack size if 50000 bytes
  99.     - default STACK size is 50000 bytes
  100.     - default trailstack size is 800 trail entries
  101.     - default number of clauses is 1000
  102.     - default functor space is 30000 bytes
  103.  
  104.     2.0 Error Handling and Debugging
  105.     
  106.     2.0.1 Fatal Errors
  107.     
  108.     Fatal errors are :
  109.     - not enough memory
  110.     - prototype space overflow
  111.     - missing main goal to start the machine
  112.     - main goal has stopped
  113.     - clause space overflow
  114.     - missing error goal, iff an recoverable error happens
  115.     - functor space overflow
  116.     - bad data during boot phase
  117.     - invalid prolog image
  118.     
  119.     Fatal errors print an message and terminate Xprolog.
  120.     
  121.     2.0.2 Lesser Errors
  122.     
  123.     These are :
  124.     - STACK overflow
  125.     - Trailstack overflow
  126.     - Copystack overflow
  127.     
  128.     These errors cause an abort of the current goal. (cf. 'abort')
  129.     They are usually caused by an loop or by generally insuffient memory.
  130.     
  131.     2.0.3 Recoverable Errors
  132.     
  133.     Recoverable Errors are counted as :
  134.     1. Unknown clause.
  135.     2. IO failure.
  136.     3. Read past EOF.
  137.     4. Bad syntax.
  138.     5. Too many args/vars.
  139.     6. Bad arguments.
  140.     7. No valid expression. 
  141.     8. User break. (control)C
  142.     
  143.     Except error 1 these error are caused by builtin predicates.
  144.     They have the following meanings :
  145.     
  146.     1. The current goal refers to an unknown clause. This is normaly due
  147.        to a typo or an incomplete program.
  148.     2. Some sort of general nastiness. Watch out !!
  149.     3. If a read, get, etc. hits the end of the current input stream,
  150.        it's argument will be unified with 'end_of_file'.
  151.        Note ! This differs from other prolog implementations.
  152.        If the programs attemps to read from this stream again, error 3
  153.        is the result.
  154.     4. This error is due to bad syntax in an prolog term.
  155.        Look at the detailed error description of the reader.
  156.     5. Xprolog has hard coded limitations for the number of arguments
  157.        of a term and the number of variables in a prototype term.
  158.        See section 1.5 'Limitations and Default Values'
  159.     6. The arguments failed the parameter check for builtins.
  160.     7. The user typed <control>C
  161.  
  162.     When an recoverable error occurs, a new goal is set up.
  163.     This is 'error(NumberOfTheError, GoalThatCausedTheError)'.
  164.     The clause error should normally print a message on the screen and
  165.     fail. However it is possible to correct the error and succeed then.
  166.     (Note that error 1 should always lead to a failure)
  167.  
  168.     2.1 Debugging Predicates
  169.     
  170.     There are few of them right now.
  171.     'debug' switches tracing on.
  172.     'nodebug' switches tracing off.
  173.     'leash(Value)' sets the amount of tracing data.
  174.     The initial value after debug is switched on is 'half'.
  175.     The following leash modes exists :
  176.     - full    trace on call, retry, exit and fail
  177.     - tight    trace on call, retry and fail
  178.     - half    trace on call and retry
  179.     - loose    trace on call
  180.     - off    no trace
  181.     
  182.     < it is assumed that the reader is familiar with the procedure >
  183.     < box control flow model. cf. the prolog primer by Clocksin and >
  184.     < Mellish >
  185.  
  186.     3. Reader and Syntax
  187.     
  188.     <far too short>
  189.  
  190.     Generally the reader expects every goal and every program term
  191.     to be finished by a dot and a new line!
  192.         
  193.     To read a prolog program (not an image), you should type
  194.     'consult(filenameinsinglequotes).'
  195.     If you want to read several files you can shorten the command to
  196.     '[filename, filename, ...].'. (cf. list syntax)
  197.     The goal 'reconsult(filenameinsinglequotes)' rereads clauses.
  198.     That means it abolishes the old clauses before asserting them
  199.     from the file. (cf. 'abolish' and 'assert')
  200.     The same effect is achieved by preceeding the filename in the
  201.     short notation by a '-'.
  202.     A special file (cf. IO predicates) is 'user'. This stands for
  203.     the terminal.
  204.     
  205.     When Xprolog is in the top level loop, it reads goals from
  206.     the terminal and tries to satisfy them.
  207.     When Xprolog consultes a file, it reads terms and tries to assert
  208.     them. You can execute goals by preceeding them by ?- or :- .
  209.     The only difference between ?- and :- is, that :- generates no
  210.     answer (ie. 'no' or 'yes') and no alternatives are tried.
  211.     
  212.     3.1 Prolog Syntax
  213.     
  214.     3.1.1 Terms
  215.     
  216.     Terms are
  217.     - constants
  218.     - variables
  219.     - structures (generally known as compound terms)
  220.     
  221.     Constants are
  222.     - integers    (all natural numbers that fit in two machine words)
  223.     - atoms        (actual atoms are structures without arguments)
  224.     The name for an atom must start with a lowercase letter and may
  225.     contain any letter, digit and the '_'.
  226.     If you want to use any character, you should enclose the name in
  227.     single quotes.
  228.     < there are some special 'standalone' character which form a >
  229.     < valid name. cf. CM 'Programming in Prolog' >
  230.     
  231.     Variables must start with an uppercase letter or with an '_'.
  232.     If you need a variable only once, you may use the anonymous
  233.     variable '_'.
  234.     
  235.     Structures comprises of a functor and a sequence of terms, it's
  236.     arguments.
  237.     A functor is characterised by the name and the arity.
  238.     (Number of arguments)
  239.     The sequence of terms must be written comma seperated in round
  240.     brackets. eg. testfunctor(first, second, third).
  241.  
  242.     3.1.2 Lists
  243.     
  244.     As lists are the most used data structures in prolog, the reader
  245.     offers a simple way of writing them.
  246.     Lists are either the empty list [] or a structure with the binary
  247.     functor '.' and two arguments, the head and tail of the list.
  248.     The standart syntax for a list like
  249.     
  250.         .
  251.            / \
  252.         first .
  253.              / \
  254.          second .
  255.                 / \
  256.          third    []
  257.          
  258.     is .(first, .(second, .(third, []))).
  259.     The simpler syntax is [first, second, third].
  260.     If the tail of the above example is not the empty list, but a
  261.     random term one can write
  262.     [first, second, third | RandomTermIsTailOfTheList].
  263.     Thus the above example could be written
  264.     [first, second, third | []] as well.
  265.     
  266.     Another notation for lists is the string.
  267.     Strings are lists of integers which correspond to ASCII characters.
  268.     Strings are written in double quotes.
  269.     "Prolog" is the same as [80, 114, 111, 108, 111, 103].
  270.  
  271.     3.2 Operators
  272.  
  273.     It is possible to declare unary and binary functors as operators.
  274.     These operators are only of interest to the reader and do not add
  275.     any computational power to Xprolog.
  276.     For instance the valid prolog term +(1,2) may as well be written
  277.     as 1 + 2.
  278.     An operator comprises of the sort of operator, the preccedence
  279.     and of the atom that should be an operator.
  280.     < For a detailed description of operators see CM >
  281.  
  282.     The following operators are hard coded in Xprolog :
  283.     (List from Xprolog sources, file init.c)
  284.     { ":-", &XFXFUNCTOR, 255},
  285.     { "?-", &FXFUNCTOR, 255},
  286.     { ":-", &FXFUNCTOR, 255},
  287.     { ";", &XFYFUNCTOR, 254},
  288.     { ",", &XFYFUNCTOR, 253},
  289.     { "spy", &FXFUNCTOR, 250},
  290.     { "nospy", &FXFUNCTOR, 250},
  291.     { "\\", &FXFUNCTOR, 60},        /* a single backslash !!! */
  292.     { "not", &FXFUNCTOR, 60},
  293.     { ".", &XFYFUNCTOR, 51},
  294.     { "is", &XFXFUNCTOR, 40},
  295.     { "=..", &XFXFUNCTOR, 40},
  296.     { "=", &XFXFUNCTOR, 40},
  297.     { "\\=", &XFXFUNCTOR, 40},
  298.     { "<", &XFXFUNCTOR, 40},
  299.     { "=<", &XFXFUNCTOR, 40},
  300.     { ">=", &XFXFUNCTOR, 40},
  301.     { ">", &XFXFUNCTOR, 40},
  302.     { "==", &XFXFUNCTOR, 40},
  303.     { "\\==", &XFXFUNCTOR, 40},
  304.     { "=:=", &XFXFUNCTOR, 40},
  305.     { "=\\=", &XFXFUNCTOR, 40},
  306.     { "@<", &XFXFUNCTOR, 40},
  307.     { "@>", &XFXFUNCTOR, 40},
  308.     { "@=<", &XFXFUNCTOR, 40},
  309.     { "@>=", &XFXFUNCTOR, 40},
  310.     { "-", &FXFUNCTOR, 31},
  311.     { "-", &YFXFUNCTOR, 31},
  312.     { "+", &YFXFUNCTOR, 31},
  313.     { "/\\", &YFXFUNCTOR, 31},
  314.     { "\\/", &YFXFUNCTOR, 21},
  315.     { "*", &YFXFUNCTOR, 21},
  316.     { "/", &YFXFUNCTOR, 21},
  317.     { "mod", &XFXFUNCTOR, 11},
  318.     { "<<", &XFXFUNCTOR, 11},
  319.     { ">>", &XFXFUNCTOR, 11},
  320.  
  321.     An operator declaration may be overridden but cannot be erased.
  322.     Operator types are : fx fy xf yf xfx xfy yfx yfy.
  323.     Operators are declared by :
  324.     'op(precedence, type, atom)'.
  325.     The precedence may be in the range 1-255. (cf. above)
  326.     
  327.     - Brackets must be seperated from an operator by a blank.
  328.     - Arguments to a structure may have a maximal precedence of 254.
  329.       If it is necessary to have higher precedences, enclose the term
  330.       in brackets.
  331.     - To use an operator as an ordinary atom, enclose it in brackets too.
  332.  
  333.     4.0 System Hooks and Hacks
  334.     
  335.     The following builtin (c defined) predicates are not intended for
  336.     use in a 'normal' prolog program but are used for interaction
  337.     and manipulation of the underlying system.
  338.     
  339.     halt.
  340.         The proper way to stop Xprolog and return to the desktop.
  341.  
  342.     abort.
  343.         Aborts the current pending goals, cleans the trail, copy
  344.         and resolutionstack and restarts the main goal.
  345.         
  346.     fileerrors.
  347.         After fileerrors was called, any error during io leads
  348.         to an error message and to an abort.
  349.         
  350.     nofilerrors.
  351.         After nofilerrorsw as called, io error lead to an failure
  352.         of the builtin predicate.
  353.         
  354.     sh.
  355.         Invokes a command shell. If the enviroment variable SHELL
  356.         is not set, the default shell will be used.
  357.         
  358.     system(atom).
  359.         Invokes the command atom through a command shell.
  360.         
  361.     statistics.
  362.         Returns some usefull statistics.
  363.         
  364.     prompt(old, new).
  365.         Unifies old and new to the old an new prompt. Usefull for
  366.         determine the current prompt or changeing the prompt.
  367.         (see _boot for an example)
  368.         
  369.     $clause(head, body, don't_touch_me)
  370.         Hook for implementing 'clause(head, body)'.
  371.         If invoked from the call port, the third argument must be
  372.         an unbound variable.
  373.         $clause tries to unify head and body with the head and body
  374.         of the first fitting clause descriptor.
  375.         The third argument is then CHANGED(literally!) to an
  376.         integer with the adress of the current clause descriptor as
  377.         it's value.
  378.         If $clause is reinvoked from the retry port, the next fitting
  379.         clause descriptor is searched and the integer is advanced.
  380.         Thus it is possible to find all clauses in the database.
  381.         If there is no further clause, the third argument is
  382.         recreated as a fresh variable.
  383.  
  384.     debug.
  385.         Switches debug mode on. Leash is set to half.
  386.         
  387.     nodebug.
  388.         Switches debug mode off.
  389.         
  390.     $functor(name, arity, don't_touch_me)
  391.         General hook. (Used in 'listing' for instance)
  392.         The third argument is used as in $clause, but holds now
  393.         the adress of the last tried functor.
  394.         $functor returns all known functors. (through backtracking)
  395.         
  396.     $goalvars(list)
  397.         Hook for the toplevel interpreter loop.
  398.         When the reader reads a prolog term, all encountered
  399.         variables and their names are stored in an internal
  400.         symbol table.
  401.         To save these variables for later purposes (prompting
  402.         the results) one should call $goalvars.
  403.         $goalvars builds a list of ',' terms that hold the variable's
  404.         name and the variable itself.
  405.         For example the term 'test(FirstVariable, _, _234)'
  406.         results in [('FirstVariable', _23), ('_234', _24)].
  407.  
  408.     $more(variable)
  409.         Hook for the toplevel interpreter loop.
  410.         $more unifies the argument with 'yes' iff there is
  411.         a backtrack log for a goal that was called after the
  412.         parents goal was called. (difficult ?)
  413.         Example: in the conjunction of goals
  414.         a, b, call(C), more(VARIABLE), d.
  415.         the VARIABLE is set to yes iff the goals a, b or the
  416.         meta goal C offers untried alternatives.
  417.         Thus $more is used to determine if the user's goal had
  418.         some alternatives.
  419.         (see _boot for a working example)
  420.  
  421.     $prompt(atom)
  422.         $prompt is used to write a prompt. It is a hack for
  423.         a programming mistake that makes Xprolog sometimes think
  424.         it has just read an empty line.
  425.         (And then it shows a new prompt which is unwanted)
  426.         < this bug will probably be removed in later versions >
  427.         
  428.     protect(list_of_structures)
  429.         All given structures (precisely their functors) are
  430.         marked as protected.
  431.         Afterwards they cannot be removed by abolish or retract.
  432.         Hint : use anonymous variables or integers as arguments.
  433.         
  434.     unprotect(list_of_structures)
  435.         Reverse the effect of protect.
  436.         
  437.     hide(list_of_structures)
  438.         All given structures are marked as hidden.
  439.         They won't be returned by $functor.
  440.         
  441.     reveal(list_of_structures)
  442.         Reverse the effects of hide.
  443.         
  444.     save(atom)
  445.         Saves the current data in the prototype space,
  446.         clause space and functor space in an image with the given name.
  447.         Note that images between different processor types are
  448.         incompatible.
  449.         The current sizes of all data areas are saved too.
  450.         If Xprolog is started with such an image, the options are
  451.         overridden by the saved area sizes.
  452.         
  453.     reboot
  454.         Restarts Xprolog without loading it again.
  455.         Usefull after the database was screwed up.
  456.         
  457.     $leash(number)
  458.         Sets the port bitmask for the tracer.
  459.         (the following lines are from Xprolog sources, prolog.h)
  460.         #define CALL_PORT     0x1
  461.         #define FAIL_PORT    0x2
  462.         #define RETRY_PORT    0x4
  463.         #define EXIT_PORT    0x8
  464.         With $leash it is possible to trace a selected set of
  465.         ports.
  466.         
  467.     reconsulting(number)
  468.         Sets the reconsulting flag to number.
  469.         If 1, reconsult mode is active, if 0 it is inactive.
  470.  
  471.     Xprolog offers a very special feature.
  472.     One can write 'special case' predicates in C and the more general
  473.     procedure in prolog. This feature is currently implemented in
  474.     the append predicate only.
  475.     The C predicate for append assumes that the first two arguments are
  476.     proper lists and unifies the appended lists with the third argument.
  477.     If this fails, the 'standard' prolog procedure is used.
  478.     (ie. append consist of three clauses, the first is a builtin
  479.     c function and the second and third are written in prolog)
  480.     < due to a bug listing can't show those procedures >
  481.     
  482.     5.0 IO Predicates
  483.     
  484.     Up to 15 streams may be open at any one time.
  485.     Everytime one stream is the current input stream and another
  486.     stream the current output stream.
  487.     If no stream is opened, the users terminal acts like a file.
  488.     This is the default stream 'user'.
  489.     Filenames must be specified as in the underlying operating system.
  490.     Filenames are simple atoms, and must be quoted if necessary.
  491.     Normaly IO error cause an abort, but if 'nofileerrors' was called,
  492.     the predicate simply fails.
  493.     The end of file of the current input stream is signalled by the
  494.     atom 'end_of_file'.
  495.     
  496.     5.1 Reading Programs
  497.     
  498.     consult(filename)
  499.         Reads the clauses in the file and asserts them. (cf. sect. 3.0)
  500.  
  501.     reconsult(filename)
  502.         Like consult, except that the procedures that will be
  503.         redefined are deleted before asserting the new clauses.
  504.         
  505.     [filename|filenames]
  506.         Each specified file in the list is consulted, or reconsulted
  507.         if the filename is preceeded by a '-'.
  508.         
  509.     5.2 File Handling
  510.     
  511.     see(filename)
  512.         The file becomes the new current input stream.
  513.         If the file was not opened yet, it will be opened.
  514.         
  515.     seeing(filename)
  516.         The filename will be unified with the name of the
  517.         current input stream.
  518.         
  519.     seen
  520.         The current input stream is closed and user becomes
  521.         the new current input stream.
  522.         
  523.     tell(filename)
  524.         Opens the file (if not open) and makes it the new
  525.         current output stream.
  526.         
  527.     telling(filename)
  528.         The filename will be unified with the name of the
  529.         current output stream.
  530.         
  531.     told
  532.         The current ouput stream is closed and user
  533.         becomes the new current output stream.
  534.         
  535.     close(filename)
  536.         Closes filename.
  537.         
  538.     fileerrors
  539.         Any IO error will cause an abort.
  540.         
  541.     nofileerrors
  542.         Any IO error will just fail the predicate.
  543.         
  544.     exists(filename)
  545.         Succeeds if the file exists and is writeable.
  546.         
  547.     rename(old, new)
  548.         Renames the file old to new.
  549.         If new is [], then old is removed.
  550.         
  551.     5.3 Input Output
  552.     
  553.     read(Term)
  554.         A term (delimited by '.' and a new line) is read and
  555.         unified with Term.
  556.  
  557.     read_line(List)
  558.         The next line is read and List is unified with the
  559.         list of characters in that line. Ie. the line
  560.         is treated as a string.
  561.         
  562.     write(Term)
  563.         The Term is written to the output stream.
  564.         
  565.     writeq(Term)
  566.         The Term is written with it's names quoted where
  567.         necessary. The output of writeq can be reread by the
  568.         reader.
  569.         
  570.     display(Term)
  571.         Same as write, but only the prefix notation of terms
  572.         is used.
  573.  
  574.     write_line(String)
  575.         The String(list of characters) is written.
  576.         The line is terminated by a line feed.
  577.         
  578.     print(Term)
  579.         Hook for including a pretty printer.
  580.         Variables are printed with write, but other terms
  581.         are written with 'portray(Term)'.
  582.         
  583.     nl.
  584.         A new line is started on the output stream.
  585.         
  586.     get0(char)
  587.         The next character is read and it's ASCII code is unified
  588.         with char.
  589.         Note that on a end of file on the current input stream
  590.         get0 returns not an integer but 'end_of_file'.
  591.         
  592.     get(char)
  593.         Same as get0, but only nonblank printable characters are
  594.         read. Other character are skipped.
  595.         
  596.     skip(char)
  597.         Skips characters until char is found.
  598.         
  599.     put(char)
  600.         Prints the character with the ASCII code char.
  601.         
  602.     tab(N)
  603.         Prints N spaces on the output stream.
  604.  
  605.     flush
  606.         Flushes the current output stream. Usefull
  607.         for buffered IO.
  608.         
  609.     seek(X)
  610.         Unifies the current position in the current input
  611.         stream with X.
  612.  
  613.     get_key(char, scancode)
  614.         Special predicate for Atari ST only.
  615.         Reads any character from the keyboard without echo!!
  616.         Returns the ASCII code in char and the scancode.
  617.         The scancode is the position information from the
  618.         keyboard. (see your copy of the Atari ST internals)
  619.  
  620.     6.0 Arithmetic
  621.     
  622.     Note that Xprolog has only integers and no floats as in
  623.     Cprolog.
  624.     
  625.     Arithmetic is performed by builtins which take arithmetic
  626.     expressions as arguments.
  627.     Valid arithmetic expresssions are (when x and y are expressions) 
  628.     
  629.     x+y        addition
  630.     x-y        subtraction
  631.     x*y        multiplication
  632.     x/y        integer division
  633.     x mod y     x modulo y
  634.     - x        minus
  635.     x /\ y        bitwise conjunction
  636.     x \/ y        bitwise disjunction
  637.     x << y        bitwise leftshift of x by y bits
  638.     x >> y        bitwise rightshift
  639.     \x        bitwise negation
  640.     cputime        number of milliseconds since Xprolog started
  641.     heapused    used space in the prototype space in bytes
  642.     [character]    the ASCCI code of the character
  643.     any Number
  644.     
  645.     Builtin predicates that evaluate expressions are
  646.     
  647.     Z is X
  648.         X is evaluated and Z is unified with the result.
  649.         
  650.     X =:= Y
  651.         The values of X and Y are equal.
  652.         
  653.     X =\= Y
  654.         The values of X and Y are not equal.
  655.         
  656.     X < Y
  657.         The value of X is less the value of Y.
  658.         
  659.     X > Y
  660.     
  661.     X =< Y
  662.     
  663.     X >= Y
  664.  
  665.     7.0 Convenience and Control
  666.     
  667.     P , Q
  668.         P and Q.
  669.         
  670.     P ; Q
  671.         P or Q.
  672.         
  673.     true.
  674.         Always succeeds.
  675.         
  676.     fail.
  677.         Never succeeds.
  678.         
  679.     X = Y
  680.         X is unified with Y. Defined as 'X=Y.'
  681.         
  682.     !
  683.         The cut. Discard all pending choices since the parent
  684.         goal was started.
  685.         
  686.     repeat
  687.         Has infinite choices.
  688.         Defined as if by :
  689.         repeat.
  690.         repeat :- repeat.
  691.  
  692.     { clause }
  693.         Same as assert((clause)).
  694.  
  695.     8.0 Meta Logic
  696.     
  697.     var(X)
  698.         X is a variable.
  699.         
  700.     nonvar(X)
  701.         X is not a variable.
  702.     
  703.     atom(X)
  704.         X is an atom.
  705.         
  706.     integer(X)
  707.         X is an integer.
  708.         
  709.     atomic(X)
  710.         X is an atom or an integer.
  711.  
  712.     structure(X)
  713.         X is a structured term. (known as compound term)
  714.         Note that atom(X) implies structure(X).
  715.  
  716.     builtin(X)
  717.         X is a built in predicate
  718.         
  719.     functor(Term, Name, Arity)
  720.         If Term is given, Name and Arity are set to the name and
  721.         arity of the Term's functor.
  722.         If Term is not given (ie. a unbound variable) a structure
  723.         is generated (with anonymous variables as arguments)
  724.         with the given name and arity.
  725.         
  726.     arg(N, Term, X)
  727.         Unifies X with the N's argument of Term.
  728.         
  729.     Term =.. List
  730.         List is a List whose head is an atom corresponding to
  731.         the functor of Term and its tail is the argument list of Term.
  732.         If Term is not given, List must be instantiated.
  733.         Examples:
  734.         product(0,N,N-1) =.. [product,0,N,N-1].
  735.         X =.. [1,a,b] will fail as 1 is no valid name.
  736.         
  737.     name(Atom, List)
  738.         If Atom is given, List will be unified with the list
  739.         of the ASCII codes of Atom's name.
  740.         If Atom is not given, it is unified with an atom whose
  741.         name is build by the list of ASCII codes.
  742.         i.e. name(prolog, "prolog").
  743.         
  744.     call(Goal)
  745.         The Goal is executed as if the Goal appeared in the
  746.         place of call(Goal). Note that the Cut ('!') is local
  747.         to the Goal.
  748.         
  749.     
  750.     9.0 Term Comparison
  751.     
  752.     X == Y
  753.         Test if X and Y are strictly equal.
  754.         
  755.     X \== Y
  756.         Test if X and Y are not strictly equal.
  757.         
  758.     X @< Y
  759.         Test if X is less than Y in the standard order.
  760.         < standard order as in Cprolog >
  761.         
  762.     X @> Y
  763.     
  764.     X @=< Y
  765.     
  766.     X @>= Y
  767.     
  768.     compare(Op, X, Y)
  769.         Aplies Op to X and Y.
  770.         Op may be '<', '>', '='.
  771.  
  772.     subatom(first, second)
  773.         Checks if the name of the first atom lies in the name
  774.         of the second atom.
  775.         
  776.     subATOM(first, second)
  777.         Like subatom but case independent.
  778.  
  779.     10.0 Database
  780.     
  781.     assert(Clause)
  782.         Same as assertz.
  783.         
  784.     asserta(Clause)
  785.         Adds the clause as the first clause of the procedure.
  786.         
  787.     assertz(Clause)
  788.         Adds the clause as the last clause of the procedure.
  789.         
  790.     clause(Head, Body)
  791.         Head must be bound to a structure.
  792.         The Database is searched for a matching clause.
  793.         Body is the unified with the body of the found clause.
  794.         If we found a fact, Body will be unified with 'true'.
  795.         Clause may be retried to get all matching clauses.
  796.         
  797.     retract(Head)
  798.         The first matching clause is remove from the database.
  799.         
  800.     abolish(Name, Arity)
  801.         Removes all clauses whose name is Name and arity is Arity.
  802.         
  803.     !! Note !! Currently no check is made to prevent a program
  804.     from retracting itself. Clauses are removed immediately.
  805.     This may result even in a crash of Xprolog !!!!
  806.